/*
 * ath20.h
 *
 *  Created on: 2023年10月12日
 *      Author: hm
 */

#ifndef APP_INC_ATH20_H_
#define APP_INC_ATH20_H_

#include "stdint.h"
#include "driver/i2c.h"
#include "driver/gpio.h"
#include "esp_types.h"

#define i2c_master_port I2C_NUM_0
#define aht20_addr    0x38
#define ACK_CHECK_EN  0x1                       /*!< I2C master will check ack from slave*/
#define ACK_CHECK_DIS 0x0                       /*!< I2C master will not check ack from slave */
#define ACK_VAL  0x0                            /*!< I2C ack value */
#define NACK_VAL 0x1                            /*!< I2C nack value */

struct aht20_data{
    float temperature;
    float rel_humidity;
}aht20_data;

esp_err_t i2c_setup(void);
void check_calibration();
bool getbit(int NUM, int n);
void trigger_measure();
void aht20_read_measures(void *ignore);

extern struct aht20_data g_aht20_data;

#endif /* APP_INC_ATH20_H_ */
